﻿
#include <QApplication>
#include <QProcess>
#include <QDir>

void initializeEnv();

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);

    initializeEnv();

    QProcess process;
    QObject::connect(&process, QOverload<int>::of(&QProcess::finished), &a, &QApplication::quit);
    process.start("target.exe");

    return a.exec();
}

void initializeEnv()
{
    QString envPath = qgetenv("PATH");

    QString appDirPath = QApplication::applicationDirPath();
    QString dependencePath = appDirPath + "/dependence";

    envPath += QDir::toNativeSeparators(dependencePath).prepend(';');

    qputenv("PATH", envPath.toStdString().c_str());
}
